import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-03-09
 * Time: 14:55
 */
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doGet(req, resp);
        //把数据显示到服务器控制台
        System.out.println("hello");
        resp.setContentType("charset=utf8");
        //把数据写回给浏览器
        resp.getWriter().write("王雅钊 ,java");
    }

    @Override
    public void init() throws ServletException {
        //可以在这里重写init方法
        //插入一些咱们自己的'初始化'相关逻辑
        System.out.println("init");
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      System.out.println("service");
    }

//    @Override
//    public void destroy() {
//        System.out.println("destroy");
//    }
}
